package com.qcq.wecheck.schedule;

import com.qcq.wecheck.util.OssUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import static com.qcq.wecheck.util.OssUtils.BACKGROUND_IMAGE_URLS;

/**
 * <p>
 * 定时器,专门执行指定io操作
 * </p>
 *
 * @author O
 * @version 1.0
 * @since 2018/9/21
 */
@Component
@Slf4j
public class IoSchedule {
	/**
	 * 每天一点钟执行刷新背景图片的url
	 */
	@Scheduled(cron = "0 0 1 * * ?")
	public void refreshUrl() {
		log.info("刷新背景图片的url ...");
		try {
			BACKGROUND_IMAGE_URLS = OssUtils.getAllUrl();
		} catch (Exception e) {
			log.error("an exception caught when refreshing oss background image urls");
		}

	}

}
